package com.stone;/*

 */

import org.apache.http.HttpHost;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * 创建索引
 * @ClassName EsTest_Client
 * @Author Final
 * @Project DataStructures
 */
public class EsTest_Doc_Delete_Batch {

    public static void main(String[] args) throws IOException {

        //创建客户端
        RestHighLevelClient esClient=new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200,"http"))
        );

        BulkRequest request=new BulkRequest();
        request.add(new DeleteRequest().index("students").id("1001"));
        request.add(new DeleteRequest().index("students").id("1002"));
        request.add(new DeleteRequest().index("students").id("1003"));
        request.add(new DeleteRequest().index("students").id("1004"));
        BulkResponse responses = esClient.bulk(request, RequestOptions.DEFAULT);

        System.out.println(responses.getItems());
        //关闭es客户端
        esClient.close();
    }
}
